package someTestExcemple.thread.communication;

public class ThreadTest {
    public static void main(String[] args) {
        //需求 3个生产者线程负责生产包子，每个线程每次只能生产一个包子放桌子上
        //2个消费者线程负责吃包子，每次只能吃一个包子
        Desk desk = new Desk();
        //三个生产者线程
        new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    desk.put();
                }
            }
        },"厨师1").start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    desk.put();
                }
            }
        },"厨师2").start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    desk.put();
                }
            }
        },"厨师2").start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    desk.get();
                }
            }
        },"顾客1").start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    desk.get();
                }
            }
        },"顾客2").start();


    }
}
